.\" -*- nroff -*-
.TH printk 9 "$Date:$" "Linux DDI" "Kernel Functions"
.SH NAME
printk \- print messages to console log
.SH SYNOPSIS
.B #include <linux/kernel.h>
.sp
.BI "int printk(const char*" fmt ", ...)"
.SH DESCRIPTION
Print a formatted message to the kernel console, much like the
.B printf
function of the stdio library. Normally, the message is written to the
physical console device of the computer, although this behavior can be
changed with the
.B register_console
function. Messages are also stored in a message log book.
.PP
The generated string may also start with a message priority code,
which sets the priority of the message. The priority code strings are
of the form
.I "<n>"
where n is a number from 0 - 7. The following macros are defined in
the
.I "<linux/kernel.h>"
header file:
.RS
.TP
KERN_EMERG
System is unuseable
.TP
KERN_ALERT
Action must be taken immediately
.TP
KERN_CRIT
Critical conditions
.TP
KERN_ERR
Error conditions
.TP
KERN_WARNING
Warning conditions
.TP
KERN_NOTICE
Normal but significant condition
.TP
KERN_INFO
Informational
.TP
KERN_DEBUG
Debug-level messages
.RE

For example
.nf

	printk(KERN_NOTICE "Hello, world.\\n");

.fi
does the expected thing.
.SH "RETURN VALUE"
Returns the number of characters written to the log.
.SH AVAILABILITY
Linux 1.0+
.SH "SEE ALSO"
.BR register_console "(9), " syslog "(2)"
.PP
.IR "kernel/printk.c"
.SH AUTHOR
Stephen Williams (steve@icarus.com)
.SH BUGS
float and double formats are not supported. Floats and doubles do not
belong inside the kernel anyhow.
.PP
The
.B printk
implementation protects itself from interruption, so in principle it
can be used in interrupts handlers and critical sections. However,
there are no guarantees about the console function that is registered.
